package com.example.demo.bo;

/**
 * @author: linliquan
 * @date: 2018/8/15 18:32
 * @description:
 */

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.awt.*;
import java.io.IOException;
import java.io.InputStream;

/**
 * 字体工具类
 * @author jane
 *
 */
class FontsUtil {
    private static final Logger logger = LoggerFactory.getLogger(FontsUtil.class);

    /**
     * 宋体
     *
     * @param style
     * @param size
     */
    public static Font getSIMSUN(int style, float size) {
        Font font = null;
        //获取字体流
        InputStream simsunFontFile = FontsUtil.class.getResourceAsStream("/fonts/msyh.ttf");
        try {
            //创建字体
            font = Font.createFont(Font.PLAIN, simsunFontFile).deriveFont(style, size);
        } catch (FontFormatException e) {
            logger.error("", e);
        } catch (IOException e) {
            font = new Font("微软雅黑", Font.BOLD, 6);
            logger.error("", e);
        }
        return font;
    }

}